package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsGrouponRules;
import com.qf.service.DtsGrouponRulesService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/groupon")
public class DtsAdminGroupOnController {
    @Autowired
    DtsGrouponRulesService grouponRulesService;

    @RequestMapping("/listRecord")
    public Object listRecord(@RequestParam(name = "page",required = false,defaultValue = "1") Integer page,
                             @RequestParam(name = "limit",required = false,defaultValue = "10")Integer limit,
                             String sort, String order){

        IPage<DtsGrouponRules> iPage=grouponRulesService.findByPage(page,limit,sort,order);
        Map<String,Object> data = new HashMap<>();
        data.put("total",iPage.getTotal());
        data.put("items",iPage.getRecords());
        return ResponseUtil.ok(data);

    }
}
